package 每日一题;

/**
 * @author 会玩的洋洋
 * https://leetcode-cn.com/problems/complex-number-multiplication/
 */
public class _537_复数乘法 {
    public String complexNumberMultiply(String num1, String num2) {
        String[] complex1 = num1.split("\\+|i");
        String[] complex2 = num2.split("\\+|i");
        Integer real1 = Integer.valueOf(complex1[0]);
        Integer image1 = Integer.valueOf(complex1[1]);
        Integer real2 = Integer.valueOf(complex2[0]);
        Integer image2 = Integer.valueOf(complex2[1]);
        return real1 * real2 - image1 * image2 + "+" + real1 * image2 + real2 * image1 + "i";
    }
}
